<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    //vue 使用 set get进行数据劫持
    const dog = {
        name: '花花',
        age: 18
    };
    //
    const d = {};
    Object.defineProperty(d, "name", {
        set(v) {
            console.log("发现了新的数据修改,开始更新数据")
            dog.name = v;
        },
        get() {
            return dog.name;
        }
    })
</script>
</body>
</html>